﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.configinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int cid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(cid);
				}
			}
		}
			
	private void ShowInfo(int cid)
	{
		lcs.BLL.configinfo bll=new lcs.BLL.configinfo();
		lcs.Model.configinfo model=bll.GetModel(cid);
		this.lblcid.Text=model.cid.ToString();
		this.txttsgj.Text=model.tsgj.ToString();
		this.txttsps.Text=model.tsps.ToString();
		this.txtygyqs.Text=model.ygyqs.ToString();
		this.txtygyjs.Text=model.ygyjs.ToString();
		this.txtpsyqs.Text=model.psyqs.ToString();
		this.txtpsyjs.Text=model.psyjs.ToString();
		this.txtgybz.Text=model.gybz.ToString();
		this.txtpsbz.Text=model.psbz.ToString();
		this.txtzlbz.Text=model.zlbz.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txttsgj.Text))
			{
				strErr+="推送供应计划时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txttsps.Text))
			{
				strErr+="推送配送计划时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtygyqs.Text))
			{
				strErr+="月供应计划起始时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtygyjs.Text))
			{
				strErr+="月供应计划结束时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtpsyqs.Text))
			{
				strErr+="配送月起始时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtpsyjs.Text))
			{
				strErr+="配送月结束时间格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtgybz.Text))
			{
				strErr+="供应班长计划分发日期格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtpsbz.Text))
			{
				strErr+="配送班长计划分发日期格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtzlbz.Text))
			{
				strErr+="质量班长计划分发日期格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int cid=int.Parse(this.lblcid.Text);
			int tsgj=int.Parse(this.txttsgj.Text);
			int tsps=int.Parse(this.txttsps.Text);
			int ygyqs=int.Parse(this.txtygyqs.Text);
			int ygyjs=int.Parse(this.txtygyjs.Text);
			int psyqs=int.Parse(this.txtpsyqs.Text);
			int psyjs=int.Parse(this.txtpsyjs.Text);
			int gybz=int.Parse(this.txtgybz.Text);
			int psbz=int.Parse(this.txtpsbz.Text);
			int zlbz=int.Parse(this.txtzlbz.Text);


			lcs.Model.configinfo model=new lcs.Model.configinfo();
			model.cid=cid;
			model.tsgj=tsgj;
			model.tsps=tsps;
			model.ygyqs=ygyqs;
			model.ygyjs=ygyjs;
			model.psyqs=psyqs;
			model.psyjs=psyjs;
			model.gybz=gybz;
			model.psbz=psbz;
			model.zlbz=zlbz;

			lcs.BLL.configinfo bll=new lcs.BLL.configinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
